﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using c2iGMailNotifier.Model;

namespace c2iGMailNotifier.Service
{
    public class SettingsReaderWriter
    {
        public static User GetCurrentUser()
        {
            string userName = Properties.Settings.Default.UserName;
            string password = Properties.Settings.Default.Password;
            string notificationSoundFileName = string.IsNullOrEmpty(Properties.Settings.Default.NotificationSoundFileName) ? "newEmail.wav" : Properties.Settings.Default.NotificationSoundFileName;
            int refreshInterval = Properties.Settings.Default.RefreshInterval;

            return new User {UserName = userName, Password = password, RefreshInterval = refreshInterval, NotificationSoundFileName = notificationSoundFileName};
        }

        public static void SetCurrentUser(User user)
        {
            Properties.Settings.Default.UserName = user.UserName;
            Properties.Settings.Default.Password = user.Password;
            Properties.Settings.Default.RefreshInterval = user.RefreshInterval;
            Properties.Settings.Default.NotificationSoundFileName = user.NotificationSoundFileName;

            Properties.Settings.Default.Save();
        }
    }
}